CFLAGS=-O3 -g
OBJS=libomp2ath_host.o libomp2ath_slave.o libomp2ath_slave_asm.o slave_stubs.o ieee_arith.o
all: libomp2ath.o omp2ath.so

libomp2ath.o: $(OBJS)
	swld -r -o $@ $^
libomp2ath_host.o: libomp2ath.c
	sw9gcc $(CFLAGS) -c $< -mhost -o $@
libomp2ath_slave.o: libomp2ath.c
	sw9gcc $(CFLAGS) -c $< -mslave -o $@
libomp2ath_slave_asm.o: libomp2ath.S
	sw9gcc $(CFLAGS) -c $< -mslave -o $@
slave_stubs.o: slave_stubs.c
	sw9gcc $(CFLAGS) -c $< -mslave -o $@
ieee_arith.o: ieee_arith.f90
	sw9gfortran $(CFLAGS) -c $< -mslave -o $@
omp2ath.so: omp2ath.cpp
	g++ $< -I$(shell sw9gfortran -print-file-name=plugin)/include -I/usr/sw/swgcc/swgcc710-tools-SEA/usr/lib_for_gcc/include/ -fno-rtti -shared -O3 -o $@ -std=gnu++11 -fPIC
.PHONY:
clean:
	rm $(OBJS) libomp2ath.a libomp2ath.o omp2ath.so